<html>
<head>
    <title>双预防系统</title>
    <link rel="stylesheet" href="../../../assets/bundle.element.css">
    <link rel="stylesheet" href="../../../style.css">

    <style>
        body {
            background: #F0F2F6;
        }

        .main-head {
            background: #fff;
            padding-left: 10px;
            padding-top: 10px;
            margin-bottom: 0px;
            border: solid 1px #fff;
        }

        .chart-outer {
            height: 200px;
        }

        .inputW {
            width: 150px;
        }

        .itemW {
            width: 200px;
        }

        .formLabelWidth {
            width: 100px;
        }

        input {
            BORDER-TOP-STYLE: none;
            BORDER-RIGHT-STYLE: none;
            BORDER-LEFT-STYLE: none;
            /*BORDER-BOTTOM-STYLE: solid*/
        }
    </style>
</head>
<body>
<div class="page" id="page-monitor">
    <div class="page-title">学校安全基本情况统计表</div>
    <div class="page-main">
        <el-row>
            <el-col :span="24">
                <div class="main-head">
                    <el-form :inline="true" size="small">
                        <el-form-item label="广播名称">
                            <el-input v-model="broadcastName" autocomplete="off" class="itemW"></el-input>
                        </el-form-item>
                        <!--<el-form-item label="" prop="startTime">-->
                        <!--<el-col :span="11">-->
                        <!--<el-date-picker type="date" placeholder="开始时间" v-model="startTime"-->
                        <!--value-format="yyyy-MM-dd" style="width: 100%;"></el-date-picker>-->
                        <!--</el-col>-->
                        <!--<el-col class="line" :span="2">-</el-col>-->
                        <!--<el-col :span="11">-->
                        <!--<el-date-picker type="date" placeholder="结束时间" v-model="endTime"-->
                        <!--value-format="yyyy-MM-dd" style="width: 100%;"></el-date-picker>-->
                        <!--</el-col>-->
                        <!--</el-form-item>-->
                        <el-form-item label="广播类型">
                            <el-select style="width: 200px;" v-model="broadcastType">
                                <el-option label="请选择" value=""></el-option>
                                <el-option label="通知公告" value="1"></el-option>
                                <el-option label="安全教育" value="2"></el-option>
                                <el-option label="校园文化" value="3"></el-option>
                                <el-option label="作息铃声" value="4"></el-option>
                                <el-option label="其他广播" value="5"></el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item label="播放类型" prop="age">
                            <el-select style="width: 200px;" v-model="playType"
                                       id="playType">
                                <el-option label="请选择" value=""></el-option>
                                <el-option label="及时" value="1"></el-option>
                                <el-option label="定时" value="2"></el-option>
                                <el-option label="常用" value="3"></el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item>
                            <el-button type="primary" @click="search">查询</el-button>
                            <el-button type="primary" @click="addBtn">添加</el-button>
                            <el-button type="primary" @click="Play">立即播报</el-button>
                        </el-form-item>
                    </el-form>
                </div>
                <el-table :data="tableData" height="660" :stripe="true" :border="true" size="mini"
                          ref="multipleTable"
                          tooltip-effect="dark"
                          style="width: 100%"
                          @selection-change="BChange" append-to-body>
                    <el-table-column
                            type="selection"
                            width="55">
                    </el-table-column>
                    <!--<el-table-column type="index" label="序号" width="50" align="center"></el-table-column>-->

                    <el-table-column prop="broadcastName" label="广播名称"></el-table-column>
                    <el-table-column prop="playResources" label="预览">
                        <template slot-scope="scope" v-if="scope.row.file">
                            <a @click="report(scope.row.file)">试听</a>
                        </template>
                    </el-table-column>
                    <el-table-column prop="broadcastType" label="广播类型">
                        <template slot-scope="scope" v-if="scope.row.broadcastType">
                            <template v-if="scope.row.broadcastType==1">
                                通知公告
                            </template>
                            <template v-if="scope.row.broadcastType==2">
                                安全教育
                            </template>
                            <template v-if="scope.row.broadcastType==3">
                                校园文化
                            </template>
                            <template v-if="scope.row.broadcastType==4">
                                作息铃声
                            </template>
                            <template v-if="scope.row.broadcastType==5">
                                其他广播
                            </template>

                        </template>
                    </el-table-column>

                    <!--<el-table-column prop="broadcastFrequency" label="广播次数"></el-table-column>-->
                    <el-table-column prop="playType" label="播放类型">
                        <template slot-scope="scope" v-if="scope.row.playType">
                            <template v-if="scope.row.playType==1">
                                及时
                            </template>
                            <template v-if="scope.row.playType==2">
                                定时
                            </template>
                            <template v-if="scope.row.playType==3">
                                常用
                            </template>
                        </template>
                    </el-table-column>
                    <el-table-column prop="resourcesType" label="资源类型">
                        <template slot-scope="scope" v-if="scope.row.resourcesType">
                            <template v-if="scope.row.resourcesType==1">
                                文本
                            </template>
                            <template v-if="scope.row.resourcesType==2">
                                音频
                            </template>
                            <template v-if="scope.row.resourcesType==3">
                                FM
                            </template>
                        </template>
                    </el-table-column>

                    <!--<el-table-column prop="zone_name" label="区域"></el-table-column>-->
                    <el-table-column prop="broadcastStatus" label="状态">
                        <template slot-scope="scope" v-if="scope.row.broadcastStatus">
                            <template v-if="scope.row.broadcastStatus==1">
                                <el-tag size="medium">未播报</el-tag>
                            </template>
                            <template v-if="scope.row.broadcastStatus==2">
                                <el-tag size="medium">已播报</el-tag>
                            </template>
                            <template v-if="scope.row.broadcastStatus==3">
                                <el-tag size="medium">已过期</el-tag>
                            </template>
                        </template>
                    </el-table-column>
                    <el-table-column prop="stationName" label="操作">
                        <template slot-scope="scope">
                            <el-button round icon="el-icon-setting" size="mini"
                                       @click="editClick(scope.row)" type="info">编辑
                            </el-button>
                            <el-button @click="removeItem(scope.row.Id)" round size="mini" icon="el-icon-delete"
                                       type="danger">删除
                            </el-button>
                        </template>
                    </el-table-column>
                </el-table>
                <div class="page-footer">
                    <el-pagination background layout="prev, pager, next" :pagesize="pagesize" :total="totalCount"
                                   :current-page.sync="pageno" @current-change="onChangePage">
                    </el-pagination>
                </div>
            </el-col>
        </el-row>
        <el-dialog :title="editMod?'编辑':'添加'" :visible.sync="addVisible" :show-close="false" style="width: 1500px"
        >
            <el-form label-width="120px" :inline="true" :model="form" ref="form">
                <el-form-item label="广播名称" prop="broadcastName" :rules="[
                             {required:true,message:'广播名称不能为空!',trigger:'blur'}]">
                    <el-input v-model="form.broadcastName"></el-input>
                </el-form-item>

                <el-form-item label="区域" prop="zone_id" :rules="[
                             {required:true,message:'区域不能为空!',trigger:'blur'}]">
                    <el-select v-model="form.zone_id" style="width: 200px;" @change="select_status()">
                        <el-option
                                v-for="item in zoneList"
                                :key="item.zone_id"
                                :label="item.zone_name"
                                :value="item.zone_id">
                        </el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="广播类型" prop="broadcastType" :rules="[
                             {required:true,message:'广播类型',trigger:'blur'}]">
                    <el-select style="width: 200px;" v-model="form.broadcastType" @change="select_status">
                        <!--<el-option label="请选择" value=""></el-option>-->
                        <el-option label="通知公告" value="1"></el-option>
                        <el-option label="安全教育" value="2"></el-option>
                        <el-option label="校园文化" value="3"></el-option>
                        <el-option label="作息铃声" value="4"></el-option>
                        <el-option label="其他广播" value="5"></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="广播次数" prop="broadcastFrequency" :rules="[
                             {required:true,message:'广播次数!',trigger:'blur'}]">
                    <el-input v-model="form.broadcastFrequency" type="number"></el-input>
                </el-form-item>
                <el-form-item label="播放类型" prop="playType" :rules="[
                             {required:true,message:'播放类型',trigger:'blur'}]">
                    <el-select style="width: 200px;" v-model="form.playType" @change="selectChanged" id="playType">
                        <!--<el-option label="请选择" value=""></el-option>-->
                        <el-option label="及时" value="1"></el-option>
                        <el-option label="定时" value="2"></el-option>
                        <el-option label="常用" value="3"></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="定时播放时间" prop="playTime" :rules="[
                             {required:true,message:'定时播放时间!',trigger:'blur'}]" v-if="playTimeShow">
                    <el-date-picker
                            v-model="form.playTime"
                            type="date"
                            value-format="yyyy-MM-dd"
                            placeholder="定时播放时间" style="width: 200px">
                    </el-date-picker>
                </el-form-item>
                <el-form-item label="播放音量" prop="playVolume" :rules="[
                             {required:true,message:'播放音量!',trigger:'blur'}]">
                    <el-input v-model="form.playVolume" type="number" placeholder="范围0-100;0为静音;不填不控制音量"></el-input>
                </el-form-item>
                <el-form-item label="资源类型" prop="resourcesType" :rules="[
                             {required:true,message:'资源类型!',trigger:'blur'}]">
                    <el-select style="width: 200px;" v-model="form.resourcesType" @change="selectChanged1"
                               id="resourcesType">
                        <!--<el-option label="请选择" value=""></el-option>-->
                        <el-option label="文本" value="1"></el-option>
                        <el-option label="音频" value="2"></el-option>
                        <el-option label="FM" value="3"></el-option>
                    </el-select>
                </el-form-item>

                <template v-if="textShow">
                    <el-form-item label="播放声音" prop="playSound" :rules="[
                             {required:true,message:'播放声音!',trigger:'blur'}]">
                        <el-select style="width: 200px;" v-model="form.playSound" @change="select_status">
                            <!--<el-option label="请选择" value=""></el-option>-->
                            <el-option label="男声" value="1"></el-option>
                            <el-option label="女声" value="2"></el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item label="播放音速" prop="playSpeed" :rules="[
                             {required:true,message:'播放音速!',trigger:'blur'}]">
                        <el-select style="width: 200px;" v-model="form.playSpeed" @change="select_status">
                            <!--<el-option label="请选择" value=""></el-option>-->
                            <el-option label="标准" value="1"></el-option>
                            <el-option label="快速" value="2"></el-option>
                        </el-select>
                    </el-form-item>

                    <el-form-item label="播放内容" prop="playContent" :rules="[
                             {required:true,message:'播放内容',trigger:'blur'}]">
                        <el-input v-model="form.playContent"></el-input>
                    </el-form-item>
                </template>
                <template v-if="audioShow">
                    <el-form-item label="播放资源" prop="playResources" :rules="[
                             {required:true,message:'播放资源!',trigger:'blur'}]">
                        <el-input v-model="form.playResources" style="width: 170px"
                                  @click.native="openAodio"></el-input>
                        <a @click="report()">试听</a>
                    </el-form-item>
                </template>
                <template v-if="FMShow">
                    <el-form-item label="播放频道" prop="playChannel" :rules="[
                             {required:true,message:'播放频道',trigger:'blur'}]">
                        <el-select style="width: 200px;" v-model="form.playChannel" @change="select_status">
                            <!--<el-option label="请选择" value=""></el-option>-->
                            <el-option label="郑州应急广播[91.2]" value="0"></el-option>
                            <el-option label="郑州应急广播[104.1]" value="1"></el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item label="时长" prop="duration" :rules="[
                             {required:true,message:'时长!',trigger:'blur'}]">
                        <el-input v-model="form.duration" type="number"></el-input>
                    </el-form-item>
                </template>
                <el-form-item label="备注" prop="note">
                    <el-input v-model="form.Note"></el-input>
                </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button @click="addVisible=false">取消</el-button>
                <el-button @click="plan_submit" type="primary">确定</el-button>
            </div>
        </el-dialog>

        <el-dialog title="音频库" :visible.sync="addVisibleAudio" :show-close="false" style="width: 1500px">
            <el-form :inline="true" size="small">
                <el-form-item label="资源类型">
                    <el-select style="width: 150px;" v-model="resourcesType">
                        <el-option label="请选择" value=""></el-option>
                        <el-option label="语音" value="1"></el-option>
                        <el-option label="文字" value="2"></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="大类">
                    <el-select style="width: 150px;" v-model="bigClass">
                        <el-option label="请选择" value=""></el-option>
                        <el-option
                                v-for="item in BigClassList"
                                :key="item.Id"
                                :label="item.Name"
                                :value="item.Id">
                        </el-option>
                    </el-select>
                </el-form-item>
                <el-form-item>
                    <el-button type="primary" @click="Asearch">查询</el-button>
                </el-form-item>
            </el-form>

            <el-table :data="AtableData" height="450" :stripe="true" :border="true" size="mini"
                      ref="multipleTable"
                      tooltip-effect="dark"
                      style="width: 100%"
                      @selection-change="userChange" append-to-body>
                <el-table-column
                        type="selection"
                        width="55">
                </el-table-column>
                <el-table-column prop="resourcesTitle" label="资源标题"></el-table-column>
                <el-table-column prop="description" label="描述"></el-table-column>
                <el-table-column prop="resourcesType" label="资源类型">
                    <template slot-scope="scope" v-if="scope.row.resourcesType">
                        <template v-if="scope.row.resourcesType==1">
                            语音
                        </template>
                        <template v-if="scope.row.resourcesType==2">
                            文字
                        </template>
                    </template>
                </el-table-column>
                <el-table-column prop="bigClassName" label="大类"></el-table-column>
                <el-table-column prop="smallClassName" label="小类"></el-table-column>
                <el-table-column prop="duration" label="时长"></el-table-column>
            </el-table>
            <div slot="footer" class="dialog-footer">
                <el-button @click="addVisibleAudio=false">取消</el-button>
                <el-button @click="selectAudio" type="primary">确定</el-button>
                <el-pagination background layout="prev, pager, next" :pagesize="Apagesize" :total="AtotalCount"
                               :current-page.sync="Apageno" @current-change="onAChangePage">
                </el-pagination>
            </div>
            <!--<div class="page-footer">-->
            <!--</div>-->
        </el-dialog>
    </div>
</div>
<script type='text/javascript' src='../../../assets/bundle.js' charset='utf-8'></script>
<script type='text/javascript' src='../../../assets/jquery-1.11.2.min.js' charset='utf-8'></script>
<script type='text/javascript' src='../../../assets/echarts.min.js' charset='utf-8'></script>
<script type='text/javascript' src='../../../js/common.js' charset='utf-8'></script>
<script type='text/javascript' src='../../../js/component.js' charset='utf-8'></script>
<script>
    var vuePage = new Vue({
        el: '#page-monitor',
        data: {
            url: SiteConfig.webApiset,
            headers: {
                uid: '',
                token: '',
            },
            commend: {},
            commendVisible: false,
            accidentGrade: '',
            startTime: '',
            endTime: '',
            editVisible: false,
            tableData: [],
            addVisible: false,
            addVisible1: false,
            pagesize: 10,
            pageno: 1,
            totalCount: 0,
            addForm: {},
            editForm: {},
            param: {},
            editMod: false,
            form: {},
            broadcastName: '',
            zoneList: [],
            playTimeShow: false,
            textShow: false,
            audioShow: false,
            FMShow: false,
            broadcastType: '',
            playType: '',
            addVisibleAudio: false,
            BData: [],
            AudioData: [],
            AtableData: [],
            Apageno: 1,
            Apagesize: 10,
            AtotalCount: 0,
            resourcesType: '',
            bigClass: '',
            BigClassList: [
                {Id: 1, Name: '常用铃声'},
                {Id: 2, Name: '平安校园'},
                {Id: 3, Name: '文化校园'},
                {Id: 4, Name: '幼儿资源'},
                {Id: 5, Name: '小学资源'},
                {Id: 6, Name: '初中资源'},
                {Id: 7, Name: '高中资源'}
            ],
            SmallClassList: [
                {
                    BigClassId: 1, data: [
                        {Id: 1, Name: '作息铃声'},
                        {Id: 2, Name: '大课间铃声'},
                        {Id: 3, Name: '升旗仪式'},
                        {Id: 4, Name: '运动会'},
                        {Id: 5, Name: '颁奖仪式'},
                        {Id: 6, Name: '考试铃声'}]
                },
                {
                    BigClassId: 2, data: [
                        {Id: 1, Name: '实验室安全'},
                        {Id: 2, Name: '防溺水'},
                        {Id: 3, Name: '用电用气'},
                        {Id: 4, Name: '卫生安全'},
                        {Id: 5, Name: '交通安全'},
                        {Id: 6, Name: '防踩踏'},

                        {Id: 7, Name: '消防安全'},
                        {Id: 8, Name: '运动安全'},
                        {Id: 9, Name: '校园及周边安全'},
                        {Id: 10, Name: '意外伤害'},
                        {Id: 11, Name: '自然伤害'},
                        {Id: 12, Name: '防爆反恐安全'},

                        {Id: 13, Name: '与人交往'},
                        {Id: 14, Name: '心理防护'},
                        {Id: 15, Name: '假日安全'},
                        {Id: 16, Name: '网络安全'},
                        {Id: 17, Name: '禁毒教育'},
                        {Id: 18, Name: '应急演练'},
                        {Id: 19, Name: '郑渊洁老师安全百科-100条'},
                    ]
                },
                {
                    BigClassId: 3, data: [
                        {Id: 1, Name: '核心价值观'},
                        {Id: 2, Name: '经典涌读'},
                        {Id: 3, Name: '校园歌曲'},
                        {Id: 4, Name: '节日常识'},
                        {Id: 5, Name: '文明礼仪'},
                        {Id: 6, Name: '美文欣赏'},
                        {Id: 7, Name: '名言感悟'},
                        {Id: 8, Name: '成语故事'},
                        {Id: 9, Name: '名人轶事'},
                        {Id: 10, Name: '英语故事'}
                    ]
                },
                {
                    BigClassId: 4, data: [
                        {Id: 1, Name: '幼儿安全教育'},
                        {Id: 2, Name: '幼儿行为习惯'},
                        {Id: 3, Name: '幼儿体操音乐'},
                        {Id: 4, Name: '幼儿歌曲'}
                    ]
                },
                {
                    BigClassId: 5, data: [
                        {Id: 1, Name: '逃生急救'},
                        {Id: 2, Name: '交通安全'},
                        {Id: 3, Name: '防溺水'},
                        {Id: 4, Name: '校内安全'},
                        {Id: 5, Name: '防灾避险'},
                        {Id: 6, Name: '饮食卫生'},
                        {Id: 7, Name: '家庭安全'}
                    ]
                },
                {
                    BigClassId: 6, data: [
                        {Id: 1, Name: '危险应对'},
                        {Id: 2, Name: '消防安全'},
                        {Id: 3, Name: '防溺水'},
                        {Id: 4, Name: '交通安全'},
                        {Id: 5, Name: '校园暴力'},
                        {Id: 6, Name: '心里健康'},
                        {Id: 7, Name: '运动安全'},
                        {Id: 8, Name: '毒品安全'},
                        {Id: 9, Name: '网络安全'},
                        {Id: 10, Name: '居家安全'},
                        {Id: 11, Name: '出游安全'}
                    ]
                },
                {
                    BigClassId: 7, data: [
                        {Id: 1, Name: '安全教育'},
                        {Id: 2, Name: '法制教育'},
                        {Id: 3, Name: '心里健康'},
                        {Id: 4, Name: '励志人生'},
                        {Id: 5, Name: '道德素养'}
                    ]
                },
            ]
        },
        created: function () {
            this.headers = {
                uid: SiteConfig.account.uId,
                token: SiteConfig.account.accessToken
            }
            $('.page').show();
            this.getZone();


        },
        methods: {
            Play() {
                if (this.BData.length > 1) {
                    this.$message({type: 'error', message: '只能选择一项'})
                    return;
                }
                else if (this.BData[0].broadcastStatus == 2) {
                    this.$message({type: 'error', message: '已播报,不可重复'})
                    return;
                }
                else if (this.BData[0].broadcastStatus == 3) {
                    this.$message({type: 'error', message: '已过期,不可重复'})
                    return;
                }

                HttpUtil.post('SchoolTimelyBroadcast/Play', {Id: this.BData[0].id}).success((res) => {
                    if (res.state == 0) {
                        this.$message({type: 'success', message: '播放成功'});
                        this.loadData();
                    }
                });

            },
            report: function (filename) {
                var file = filename ? filename : this.form.file;
                window.open(SiteConfig.webApiset + file);
            },
            selectAudio() {
                this.form.playResources = this.AudioData[0].resourcesTitle;
                this.form.file = this.AudioData[0].file;
                if (this.AudioData.length > 1) {
                    this.$message({type: 'error', message: '只能选择一项'})
                    return;
                }
                this.addVisibleAudio = false;
            },
            BChange(val) {
                this.BData = val;
                console.log(this.BData)
            },
            userChange(val) {
                this.AudioData = val;
                console.log(this.AudioData)
            },
            openAodio() {
                this.addVisibleAudio = true;
                this.loadAudioData();
                this.AudioData.length = 0;
            },
            selectChanged1(value) {
                if (parseInt(value) == 1) {
                    this.textShow = true;
                    this.audioShow = false;
                    this.FMShow = false;
                }
                else if (parseInt(value) == 2) {
                    this.textShow = false;
                    this.audioShow = true;
                    this.FMShow = false;
                }
                else if (parseInt(value) == 3) {
                    this.textShow = false;
                    this.audioShow = false;
                    this.FMShow = true;
                }

                this.$forceUpdate();
                console.log(value)
            },
            selectChanged(value) {
                if (parseInt(value) == 2) {
                    this.playTimeShow = true;
                }
                else {
                    this.playTimeShow = false;
                }
                this.$forceUpdate();
                console.log(value)
            },
            getZone() {
                HttpUtil.get('Zone/List', {projectNo: SiteConfig.account.projectNo, pagesize: 200}).success((res) => {
                    this.zoneList = res.data;
                    this.loadData();
                });
            },
            select_status() {
                this.$forceUpdate();
            },
            plan_submit() {
                if (!this.form.broadcastName) {
                    this.$message({type: 'error', message: '广播名称不能为空'})
                    return;
                }
                if (!this.form.zone_id) {
                    this.$message({type: 'error', message: '区域不能为空'})
                    return;
                }
                if (!this.form.broadcastType) {
                    this.$message({type: 'error', message: '广播类型不能为空'})
                    return;
                }
                if (!this.form.broadcastFrequency) {
                    this.$message({type: 'error', message: '广播次数不能为空'})
                    return;
                }

                if (!this.form.playType) {
                    this.$message({type: 'error', message: '播放类型不能为空'})
                    return;
                }
                else if (parseInt(this.form.playType) == 2) {
                    if (!this.form.playTime) {
                        this.$message({type: 'error', message: '定时播放时间不能为空'})
                        return;
                    }
                }
                if (!this.form.playVolume) {
                    this.$message({type: 'error', message: '播放音量不能为空'})
                    return;
                }
                if (!this.form.resourcesType) {
                    this.$message({type: 'error', message: '资源类型不能为空'})
                    return;
                }
                else if (parseInt(this.form.resourcesType) == 1) {
                    if (!this.form.playSound) {
                        this.$message({type: 'error', message: '播放声音不能为空'})
                        return;
                    }
                    if (!this.form.playSpeed) {
                        this.$message({type: 'error', message: '播放音速不能为空'})
                        return;
                    }
                    if (!this.form.playContent) {
                        this.$message({type: 'error', message: '播放内容不能为空'})
                        return;
                    }
                }
                else if (parseInt(this.form.resourcesType) == 2) {
                    if (!this.form.playResources) {
                        this.$message({type: 'error', message: '播放资源不能为空'})
                        return;
                    }
                }
                else if (parseInt(this.form.resourcesType) == 3) {
                    if (!this.form.playChannel) {
                        this.$message({type: 'error', message: '播放频道不能为空'})
                        return;
                    }
                    if (!this.form.duration) {
                        this.$message({type: 'error', message: '时长不能为空'})
                        return;
                    }
                }

                this.form.projectNo = SiteConfig.account.projectNo;
                if (!this.editMod) {
                    HttpUtil.get('SchoolTimelyBroadcast/Add', this.form).success((r) => {
                        if (r.state == 0) {
                            this.$message.success('添加成功');
                            this.addVisible = false;
                            this.loadData();
                        } else {
                            this.$message.warning('添加失败');
                        }
                    })
                } else {

                    HttpUtil.get('SchoolTimelyBroadcast/Update', this.form).success((r) => {
                        if (r.state == 0) {
                            this.$message.success('保存成功');
                            this.addVisible = false;
                            this.loadData();

                        } else {
                            this.$message.warning('修改失败');
                        }
                    })
                }
            },
            editClick(row) {
                this.form = Object.assign(this.form, row);
                this.form.broadcastType = row.broadcastType ? row.broadcastType.toString() : '';
                this.form.playType = row.playType ? row.playType.toString() : '';
                this.form.resourcesType = row.resourcesType ? row.resourcesType.toString() : '';
                this.form.playSound = row.playSound ? row.playSound.toString() : '';
                this.form.playSpeed = row.playSpeed ? row.playSpeed.toString() : '';
                this.form.playChannel = row.playChannel ? row.playChannel.toString() : '';

                if (parseInt(row.resourcesType) == 1) {
                    this.textShow = true;
                    this.audioShow = false;
                    this.FMShow = false;
                }
                else if (parseInt(row.resourcesType) == 2) {
                    this.textShow = false;
                    this.audioShow = true;
                    this.FMShow = false;
                }
                else if (parseInt(row.resourcesType) == 3) {
                    this.textShow = false;
                    this.audioShow = false;
                    this.FMShow = true;
                }
                else {
                    this.textShow = false;
                    this.audioShow = false;
                    this.FMShow = false;
                }

                if (parseInt(row.playType) == 2) {
                    this.playTimeShow = true;
                }
                else {
                    this.playTimeShow = false;
                }
                this.$forceUpdate();

                this.addVisible = true;
                this.editMod = true;
                $('#playType').change();
                $('#resourcesType').change();
            },
            removeItem: function (id) {
                if (!id) {
                    this.$message({
                        type: 'info',
                        message: 'id为空'
                    });
                    return;
                }
                this.$confirm('此操作将永久删除, 是否继续?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning',
                    center: true
                }).then(() => {
                    HttpUtil.get('SchoolTimelyBroadcast/Delete', {Id: id}).success((r) => {
                        if (r.state == 0) {
                            vuePage.$message({
                                type: 'success',
                                message: '删除成功!'
                            });
                            vuePage.loadData();
                        } else {
                            vuePage.$message.error('删除失败!');
                        }
                    })
                }).catch(() => {
                    this.$message({
                        type: 'info',
                        message: '已取消删除'
                    });
                });

            },
            onChangePage(page) {
                this.pageno = page;
                this.loadData();
            },
            onAChangePage(page) {
                this.Apageno = page;
                this.loadAudioData();
            },
            loadData: function () {
                var param = {};
                if (this.broadcastName)
                    param.broadcastName = this.broadcastName;
                if (this.broadcastType)
                    param.broadcastType = this.broadcastType;
                if (this.playType)
                    param.playType = this.playType;
                if (SiteConfig.account.projectNo)
                    param.projectNo = SiteConfig.account.projectNo;
                param.pageno = this.pageno;
                param.pagesize = this.pagesize;

                HttpUtil.get('SchoolTimelyBroadcast/List', param).success((res) => {
                    vuePage.tableData = res.data;
                    vuePage.totalCount = res.total;

                    var List = res.data;
                    this.totalCount = res.total;

                    var zoneList = this.zoneList;
                    for (var i = 0; i < List.length; i++) {
                        for (var j = 0; j < zoneList.length; j++) {
                            if (List[i].zone_id == zoneList[j].zone_id) {
                                List[i].zone_name = zoneList[j].zone_name;
                            }
                        }
                    }
                    this.tableData = List;
                });
            },
            loadAudioData: function () {
                var param = {};
                if (this.resourcesType)
                    param.resourcesType = this.resourcesType;
                if (this.bigClass)
                    param.bigClass = this.bigClass;
                if (SiteConfig.account.projectNo)
                    param.projectNo = SiteConfig.account.projectNo;

                param.pageno = this.Apageno;
                param.pagesize = this.Apagesize;
                HttpUtil.get('SchoolAudioLibrary/List', param).success((res) => {
                    var obj = res.data;
                    var b = this.BigClassList;
                    var s = this.SmallClassList;

                    for (var i = 0; i < obj.length; i++) {
                        for (var j = 0; j < b.length; j++) {
                            if (parseInt(obj[i].bigClass) == b[j].Id)
                                obj[i].bigClassName = b[j].Name;
                        }
                    }

                    for (var i = 0; i < obj.length; i++) {
                        for (var j = 0; j < s.length; j++) {
                            if (parseInt(obj[i].bigClass) == s[j].BigClassId) {
                                for (var k = 0; k < s[j].data.length; k++) {
                                    if (parseInt(obj[i].bigClass) == s[j].data[k].Id) {
                                        obj[i].smallClassName = s[j].data[k].Name;
                                    }
                                }
                            }
                        }
                    }

                    vuePage.AtotalCount = res.total;
                    vuePage.AtableData = obj;

                });
            },
            addBtn: function () {
                this.form = {};
                this.editMod = false;
                this.addVisible = true;
            },
            search: function () {
                this.loadData();
            },
            Asearch: function () {
                this.loadAudioData();
            },
        },
        mounted: function () {

        }
    });
</script>
</body>
</html>
